/**
 * 
 */
package com.senyint.imsdk;

/**
 *
 */
public class SharedPreferencesHelper {
	private SharedPreferences preferences ;
	
	public SharedPreferencesHelper() {
		preferences = new SharedPreferences();
	}
	
	public SharedPreferencesHelper(String name) {
		preferences = new SharedPreferences(name);
	}
	
	public void removeAttribute(String key){
		preferences.edit().remove(key).commit();
	}
	
	public void setAttribute(String key,String val){
		preferences.edit().putString(key, String.valueOf(val) ).commit();
	}
	
	public void setAttribute(String key,Integer val){
		preferences.edit().putInt(key, val ).commit();
	}
	
	public void setAttribute(String key,Long val){
		preferences.edit().putLong(key, val ).commit();
	}
	
	public void setAttribute(String key,Boolean val){
		preferences.edit().putInt(key, val?1:0 ).commit();
	}
	
	public String getString(String key){
		return preferences.getString(key, null) ;
	}
	
	public String getString(String key,String defValue){
		return preferences.getString(key, defValue) ;
	}
	
	public Integer getAttribute(String key,Integer defValue){
		return preferences.getInt(key, defValue) ;
	}
	
	public Long getAttribute(String key,Long defValue){
		return preferences.getLong(key, defValue) ;
	}
	
	public Boolean getAttribute(String key){
		return preferences.getInt(key,Configuration.ACTION_NONE) == Configuration.ACTION_DONE ;
	}

}
